package rsj.api.product;

import com.rlyy.aibase.utils.base.Box;
import common.util.Assert;
import common.util.BoxUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import rsj.api.product.entity.Product;
import rsj.service.product.IProductService;

import java.util.List;

/**
 * 产品
 *
 * @author yuanqinglong
 * @since 2021/7/16 11:51
 */
@RestController
public class ProductController {


    @Autowired
    private IProductService productServiceImpl;


    /**
     * 产品类别列表
     *
     * @param param 参数
     * @return {@link Box}
     */
    @RequestMapping(value = "rsj_product_all")
    public Box productList(Box param) {
        // 返回全部 不分类
        List<Product> productList = productServiceImpl.productList();
        return BoxUtil.successBoxToTableData(param, productList);
    }

    /**
     * 帐户配置的产品
     *
     * @param param 参数
     * @return {@link Box}
     */
    @RequestMapping(value = "rsj_product_configured_get")
    public Box accountConfigurationProducts(Box param) {
        String orgId = param.getMapNode("data").getValue("org_id");
        Assert.isNotBlank(orgId, "机构id不可为空");
        List<Product> productList = productServiceImpl.accountConfigurationProducts(orgId);
        return BoxUtil.successBoxToTableData(param, productList);
    }

}
